<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
	<title>库存管理-库存报损</title>
	<meta charset="utf-8">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>libs/bootstrap-3.3.7-dist/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/reset.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/style.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/iframe.css">
</head>
<body>
	<div id="mainContent">
		<div id="mainContent_content">
			<div class="page_header"><a>库存报损</a></div>
			<div class="search">
			<form action="<%=basePath %>inventoryLoss/selectByWhere.do" method="post" class="form">
				<input type="hidden" name="currentPage" value="1">
				<p>
					<label>报损单号</label>
					<input type="text" class="form-control" name="lossNumber" value="${lossListPage.lossNumber }"></input>
					<label>状态</label>
					<select name="status" class="form-control select">
						<option value="">全部</option>
						<option value="1" <c:if test="${lossListPage.status=='1'}">selected</c:if>>已提交</option>
						<option value="0" <c:if test="${lossListPage.status=='0'}">selected</c:if>>未提交</option>
					</select>
					<label>报损说明</label>
					<input class="form-control doubleWidth" type="text" name="lossDescription" value="${lossListPage.lossDescription }"></input>
				</p>
				<p>
					<label>提交人</label>
					<input type="text" class="form-control" name="submitterName" value="${lossListPage.submitterName }">
					<label>提交时间</label>
					<input type="text" class="form-control" name="startTime" readonly onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" value="${lossListPage.startTime }"></input>
					<label>至</label>
					<input type="text" class="form-control" name="endTime" readonly onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" value="${lossListPage.endTime }"></input>
					<span class="btn">
						<input type="submit" class="btn btn1" value="查询"></input>
						<input type="button" class="btn btn2" value="清空" onclick="clearSearchParam();"></input>
						<c:if test="${isAdd }">
						<input type="button" class="btn btn1" value="新增" onclick="addReturnRequest();"></input>
						</c:if>
					</span>
				</p>
				</form>
			</div>
			<div class="tableBox box">
				<table class="table table-bordered table_text_center">
					<thead>
						<tr>
							<th style="width:150px;">操作</th>
							<th>报损单号</th>
							<th>报损说明</th>
							<th>品项数</th>
							<th>状态</th>
							<th>提交时间</th>
							<th>提交人</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${lossList }" var="loss" varStatus="i">
							<tr id="${loss.inventorylossid }">
								<td>
									<a class="btn btn-xs btn1" onclick="editLoss(${loss.inventorylossid });">详情</a>
									<c:if test="${loss.status=='0' && loss.createpersonid==userID && isAdd }">
										<a class="btn btn-xs btn2" onclick="confirmDeleteLoss(${loss.inventorylossid },${loss.createpersonid });">删除</a>
									</c:if>
									<c:if test="${loss.status=='0' && loss.createpersonid!=userID && isEditAll }">
										<a class="btn btn-xs btn_danger" onclick="confirmDeleteLoss(${loss.inventorylossid },${loss.createpersonid });">删除</a>
									</c:if>
								</td>
								<td><a onclick="editLoss(${loss.inventorylossid });">${loss.lossnumber}</a></td>
								<td>${loss.lossdescription }</td>
								<td>${loss.number }</td>
								<td>
									<c:if test="${loss.status==0 }">未提交</c:if>
									<c:if test="${loss.status==1 }">已提交</c:if>
								</td>
								<td><fmt:formatDate value="${loss.commitTime }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<td>${loss.submitterName }</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<jsp:include page="/jsp/basic/page.jsp"></jsp:include>
		</div>
		<jsp:include page="/jsp/basic/prompt.jsp"></jsp:include>
	</div>
	<script src="<%=basePath %>js/jquery-3.2.1.min.js"></script>
	<script src="<%=basePath %>libs/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
	<script src="<%=basePath %>My97DatePickers/WdatePicker.js"></script>
	<script src="<%=basePath %>js/public.js"></script>
	<script type="text/javascript">
	
	function clearSearchParam(){
		$(".search input:text").val("");
		$(".search select").val("");
	}
	
	function editLoss(id){
		location.href="<%=basePath %>inventoryLoss/toEdit.do?inventorylossid="+id;
	}
	
	function addReturnRequest(returnRequestID){
		location.href="<%=basePath %>inventoryLoss/toAddInventoryLoss.do";
	}
	
	 //删除库存报损
	function confirmDeleteLoss(id,userID){
		var delFunc=function(){
			$.ajax({
				url:"<%=basePath %>inventoryLoss/deleteInventoryLossById.do",
				type:"post",
				async : false,
				dataType:"json",
				data : "inventoryLossID="+id+"&p_userid="+userID,
				success:function(data){
					if(data.result=="success"){
						Prompt.alert("删除提示","删除成功！",Prompt.refresh);
					}else{
						Prompt.alert("提示","删除失败！");
					}
				},
				error :function(){
					Prompt.alert("删除提示","服务器无响应，请刷新页面后重试！");
				}
			});
		}
		Prompt.confirm("提示","确认要删除吗？删除后无法恢复",delFunc);
	}
	
	</script>
</body>
</html>